package com.sq.util;

import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author sq
 *
 */
public class Base64Util {

    private static Logger log = LoggerFactory.getLogger(Base64Util.class);

    /**
     * BASE64编码
     */
    public static String encode(byte[] bstr) {
        return Base64.encodeBase64String(bstr);
    }

    /**
     * BASE64解码
     */
    public static byte[] decode(String str) {
        byte[] bt = null;
        try {
            bt = Base64.decodeBase64(str);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }

        return bt;
    }
}
